<!-- 登录界面-->
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8" />
  <meta name="divport" content="width=device-width,initial-scale=1,user-scalable=no" />
  <meta name="format-detection" content="telephone=no,email=no,date=no,address=no" />
	<title>登录界面</title>
	<link rel="stylesheet" href="../plugin/hhframe/hhframe.min.css" />
	<link rel="stylesheet" href="../style/index.css"/>
	<style>
			body {
				background-color:#fff;
			}
			.header-bc{
				background-color: #fff;
			}

			.index-header{
				display: flex;
				height: 50px;
				width: 100%;
				justify-content: center;
				align-items: center;
				/*background-color: #fff;*/
				color: #000001;
				font-size:18px;
			}
			.index-nav{
				display: flex;
				height: 50px;
				width:100%;
				justify-content:space-around;
				align-items: center;
				background-color: #fff;
				color: #FEFEFE;
				font-size: 15px;
			}
			.xiahuaxian-row{
				position:relative;
			}
			.xiahuaxian{
				position: absolute;
				top: -5px;
				left: -7px;
				width: 75px;
				height: 8px;
				float:left;
				border-radius:4px;
				background: linear-gradient(to right, rgba(246,224,166,0.9) ,rgba(196,161,98,0.9));
			}
			.bott{
					display: flex;
					flex-direction: column;
					justify-content: center;
					align-items:center;
					padding: 0.36rem 0.40rem;
					margin-top: 1.20rem;
					font-size: 0.30rem;
				}
				.bott-btn{
					margin-top: 0.4rem;
					font-size: 0.30rem;
					color: #A48347;
					width: 6rem;
					height: 1rem;
					border-radius: 0.50rem;
					display: flex;
					justify-content: center;
					align-items: center;
					background: linear-gradient(to right ,#F6E0A6 , #C4A162 );
				}
				.bott-btn1{
					margin-top: 0.4rem;
					font-size: 0.30rem;
					color: #A48347;
					width: 6rem;
					height: 1rem;
					border-radius: 0.50rem;
					display: flex;
					justify-content: center;
					align-items: center;
					border: solid #A48347 1px;
					/*background: linear-gradient(to right ,#F6E0A6 , #C4A162 );*/
				}
				.top{
					margin-top: 0.20rem;
					background-color: #FFFFFF;
				}
				.row{
					display: flex;
					padding: 0.36rem 0.28rem;

				}
				.row-title{
					font-size: 0.32rem;
					color: #333333;
					margin-top: 0.06rem;
				}
				.row-inp{
					flex-grow:1;
				}
				.inp{
					width: 100%;
					border: solid #F8F8F8 0px;
					padding-top: 0.05rem;
				}
				.login-img{
					width: 1.50rem;
					height: 2.60rem;
				}
				.login-img1{
					width: 0.4rem;
					height: 0.4rem;
					margin-right: 0.1rem;
				}
				.login-log{
					display: flex;
					justify-content: center;
					margin-top: 2rem;
				}
				.title{
					margin: 0.7rem 0.5rem;
					color: 383642;
					font-size: 	0.5rem;
				}
				.submit1{
					margin-top:.60rem;
					width: 6.90rem;
					height: .90rem;
					display: flex;
					justify-content: center;
					align-items: center;
					background: #00c800;
					color: #fff;
					line-height: .60rem;
					border-radius:0.1rem;
					font-size: .32rem;
				}
				.submit2{
					margin-top: .60rem;
					width: 6.90rem;
					height: .90rem;
					display: flex;
					justify-content: center;
					align-items: center;
					background: #ff502d;
					color: #fff;
					line-height: .60rem;
					border-radius:0.1rem;
					font-size: .32rem;
				}
				.daili{
					display: flex;
					justify-content: center;
					align-items: center;
					margin-top: 4rem;
				}
				.daili img{
					width: 0.6rem;
					height: 0.6rem;
					margin-right: 0.2rem;

				}


	</style>
</head>
<body>
	<!-- 标题栏 -->
	<div class="app">


		<div id="header" class="header-bc framepage">
			<div v-if="isbz" style="height:0.9rem ;position: absolute;color: #fff;line-height: 45px;padding: 0 20px;display:flex;align-items: center;" onclick="closeWin()">
				<img src="../image/guanbi.png" style="height:0.3rem" alt="">
					<!-- <div style="transform: rotateY(180deg);font-size: 20px;font-weight: 600;" class="iconfont iconguanbi"></div> -->
			</div>
			<div class="index-header">
					<!-- 登录界面 -->
			</div>
		</div>
		<div class="content app">
			<div class="title">
				请先登录/注册
			</div>
			<div class="bott" >
				<div class="submit1" @click="login()" v-if="iswx">
					微信登录/注册
				</div>
				<div class="submit2" v-if="ishpone" @click="login_phone()">
					手机号登录/注册
				</div>
				<input type2="hidden"  style="display:none" name="jpushid" class="pid" />
			</div>
			<div class="daili" @click="jxszc" v-if="iswx" >
				<img src="../image/daili.png" alt="">
				经销商注册
			</div>
		</div>
	</div>

</body>
<script src="../plugin/jquery.js"></script>
<script src="../plugin/vue.all.js"></script>
<script src="../plugin/hhframe/hhframe.min.js"></script>
<script src="../plugin/public.js"></script>
<script src="../plugin/Jpush.js"></script>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript">
window.addEventListener("apiready",function(){

	// 实现沉浸式状态栏效果
	$api.fixStatusBar(header);
	// 极光推送
	Jpushid_Init(".pid");
	index()

});

function index()
{
	var vm = new Vue({
		el: ".app",
		data: {
			isIndex:0,
			list:[1,2,3],
			ishpone:false,
			iswx:false,
			isbz:false,
		},
		mounted: function(){
			this.isbz = api.pageParam.isbz ? api.pageParam.isbz : false
			console.log(this.isbz);
			if(!this.isbz){
				// 按两次返回键退出
				KeybackExitApp();
			}
      // 监听页面打开
			api.addEventListener({
			    name: 'viewappear'
			}, function(ret, err) {
				// 设置状态栏颜色  dark/黑色  light/白色
				setTimeout(function() {
					api.setStatusBarStyle({
						style: 'dark'
					});
				}, 250)
			});

			this.isOpenPhoneLogin()

		},
		methods: {
			// 跳转详情
			login_phone:function (id) {
				api.openWin({
						name: "login_phone",
						url: "./login_phone.html",
						slidBackEnabled: false,//是否设置为单列对象
						animation: {
								type:"push",                //动画类型（详见动画类型常量）
								duration:300,               //动画过渡时间，默认300毫秒
								subType: 'from_right',
						},
						pageParam: {
								id: id
						}
				});
			},
			//获取手机号登录标志
			isOpenPhoneLogin: function (){
				AjaxSafe({
			   		url:"/xapp/app/login/isOpenPhoneLogin",
			    	loader:false,
					success: function(res) {
						if (res.state) {

								vm.ishpone = res.data.isOpenPhoneLogin
								vm.iswx = res.data.isOpenWeChatLogin
						}
					},
					failed: function(err){
							alert("网络故障！");
					}
				});
			},
			// 经销商注册
			jxszc(){
			  this.login(true)
			},

		  login(is = false) {
				var wx = api.require('wx');
				wx.auth({
				    apiKey: ''
				}, function(ret1, err) {
				    if (ret1.status) {
								wx.getToken({
								    apiKey: '',
								    apiSecret: '',
								    code: ret1.code
								}, function(ret2, err) {
									console.log(33);
								    if (ret2.status) {
												wx.getUserInfo({
												    accessToken: ret2.accessToken,
												    openId: ret2.openId
												}, function(ret3, err) {
												    if (ret3.status) {
																AjaxSafe({
																	url: "/xapp/app/login/weixin",
																	data: {
																			unionid: ret3.unionid,
																			openid: ret3.openid,
																			headimgurl: ret3.headimgurl,
																			nickname: ret3.nickname,
																			province: '',
																			city: '',
																			jpushid: $(".pid").val()
																	},
																	success: function(ret4){
																			if( ret4.msg == "success" )
																			{
																				localdata.set("userinfo",ret4.data);
																				hhWin.shut(500);
																				if(is){
																					agency_register()
																				}else{
																					open_menu(1);
																				}


																			}
																			else
																			{
																				Jpushid_Init(".pid");
																				hhPanel.msg(ret.msg);
																			}
																	},
																	failed: function(err){

																	}
															});
												    } else {
												        alert(err.code);
												    }
												});
								    } else {
								        alert(err.code);
								    }
								});
				    } else {
				        alert(err.code);
				    }
				});
			}


		},


	});
}


</script>
</html>
